package org.hsqldb.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;

public class IncompatibleData {

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    Class.forName("org.hsqldb.jdbc.JDBCDriver");
    Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:db", "sa", "");
    Statement stmt = c.createStatement();
    stmt.execute("create table dual (c0 integer)");
    stmt.executeUpdate("insert into dual values (2)");
    
    ResultSet set = stmt.executeQuery("select to_number(to_char((select current_timestamp + c0  day from dual), 'YYYYMMDD')) from dual");
    if (set.next()) {
      System.out.println("stmt res="+set.getInt(1));
    }
    set.close();
    
    PreparedStatement pstmt = c.prepareStatement("select to_number(to_char((select ? + c0  day from dual), 'YYYYMMDD')) from dual");
    pstmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
    set = pstmt.executeQuery();
    if (set.next()) {
      System.out.println("pstmt res="+set.getInt(1));
    }
    c.close();
  }

}
